<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>角色管理</title>
		<link href="../../../component/pear/css/pear.css" rel="stylesheet" />
		<style>
			.layui-card-body .layui-form-item{
				margin-bottom: 0px;
			}
		</style>
	</head>
	<body class="pear-container">
		<div class="layui-card">
			<div class="layui-card-body">
				<form class="layui-form" action="">
					<div class="layui-form-item">
						<div class="layui-form-item layui-inline">
							<label class="layui-form-label">权限名称</label>
							<div class="layui-input-inline">
								<input type="text" name="Keyword" placeholder="" class="layui-input">
							</div>
						</div>
						<div class="layui-form-item layui-inline">
							<button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="power-query">
								<i class="layui-icon layui-icon-search"></i>
								查询
							</button>
							<button type="reset" class="pear-btn pear-btn-md">
								<i class="layui-icon layui-icon-refresh"></i>
								重置
							</button>
						</div>
					</div>
				</form>
			</div>
		</div>
		<div class="layui-card">
			<div class="layui-card-body">
				<table id="power-table" lay-filter="power-table"></table>
			</div>
		</div>
		
		<script type="text/html" id="power-toolbar">
			<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
				<i class="layui-icon layui-icon-add-1"></i>
				新增
			</button>
			<button class="pear-btn pear-btn-danger pear-btn-md" lay-event="batchRemove">
				<i class="layui-icon layui-icon-delete"></i>
				删除
			</button>
		</script>
		
		<script type="text/html" id="power-bar">
			<button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="see"><i class="layui-icon  layui-icon-edit"></i></button>
		</script>
	
		<input id="id" type="text" class="layui-hide"/>

		<script src="../../../component/layui/layui.js"></script>
		<script src="../../../component/pear/pear.js"></script>
		<script>
		    layui.use(['table','form','jquery','permission','context','popup','common'],function () {
		        let table = layui.table;
		        let form = layui.form;
		        let $ = layui.jquery;
				let common = layui.common;
				let permission = layui.permission;
				let context = layui.context;
				let popup = layui.popup;
		
		        let basePath = context.get("base-path");
		
		        let cols = 
				[[
		                {type:'checkbox'},
		                {title: '编号', field: 'id', align:'center', width:100},
		                {title: '名称', field: 'uniqueName', align:'center'},
		                {title: '描述', field: 'remark', align:'center'},
						{title: '操作', toolbar: '#power-bar', align:'center', width:195}
		        ]]
		
		        table.render({
		            elem: '#power-table',
		            url: basePath + '/api/security/list',
		            page: true ,
		            cols: cols ,
		            skin: 'line',
		            toolbar: '#power-toolbar',
		            defaultToolbar: [{
		            	layEvent: 'refresh',icon: 'layui-icon-refresh'},
		            	 'exports',
		            	 'filter',
		            	 'print'
		            ],
		            request: {
		                pageName: 'PageIndex',
		                limitName: 'PageSize' 
		            },
		            parseData: function(res){ 
		                return {
		                  "count": res.data.totalCount,
		            	  'statusCode': res.statusCode,
		            	  'data':res.data.items
		                };
		            },
		            response: {
		                statusName: 'statusCode',
		                statusCode: 200
		            }
		        });
		
		        table.on('toolbar(power-table)', function(obj){
		            if(obj.event === 'add'){
		                window.add();
		            } else if(obj.event === 'refresh'){
		                window.refresh();
		            } else if(obj.event === 'batchRemove'){
		                window.batchRemove(obj);
		            }
		        });
		
		        form.on('submit(power-query)', function(data){
		            table.reload('power-table',{where:data.field})
		            return false;
		        });
		
		        window.refresh = function(){
		            table.reload('power-table');
		        }
		    })
		</script>
	</body>
</html>
